/**
 * \file   iirfilter.h
 *         Implements a IIR filter
 * \author Manuel Leiva , Esteban Zu?iga, Jorge Hidalgo
 * \date   2012.03

 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 *
 * $Id: iirfilter.h $
 */

#ifndef IIRFILTER_H
#define IIRFILTER_H

#include "common_defs.h"

class iirfilter {

public:

    struct tIirMainStructure  {
        int      iir_order;
        float    iir_fc1;
        float    iir_fc2;
        eIirType iirType;
        double   iir_atenuation;

        /* Temporal buffer */
        float iir_out_tmp;
        float iir_w_n[MAX_IIR_ORDER];
        float iir_coefs[2 * MAX_IIR_ORDER]; // Coefficients Buffer arguments for Cascade quadratic equations
        float iir_w_tmp;
    } tIirMainStruct_;

    iirfilter();
    ~iirfilter();

    /* Init the filter operation */
    void init(tIirMainStructure *tIirMainStruct_);

    /* Filter the in buffer and leave the result in out */
    void filter(
        int blockSize,
        float* in,
        float* out,
        tIirMainStructure *tIirMainStruct_);

    /* Reset the filter */
    void reset(tIirMainStructure *tIirMainStruct_);

    /*
     * Set Coefficients for quadratics cascade implementation value in use.
     */
    void setArguments(tIirMainStructure *tIirMainStruct_);

    void GetIirInfo (tIirMainStructure* tIirMainStruct_);
};

#endif // IIRFILTER_H
